﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using CDOP.Model;

namespace CDOP.Charts
{
    public partial class DynamicChart : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                if (Session["LoggedUser"] == null)
                    Response.Redirect("../Login.aspx");
        }

        protected void DdColumnsSelectedIndexChanged(object sender, EventArgs e)
        {
            var columnName = ddColumns.SelectedValue;
            var dataRef = Chart.GetDynamicChartData(columnName);
            ChartColumn.Series["SeriesData"].Points.DataBindXY(dataRef, columnName, dataRef, "Count");
            ChartPie.Series["SeriesData"].Points.DataBindXY(dataRef, columnName, dataRef, "Count");
            grdDynamiCChart.DataSource = dataRef;
            grdDynamiCChart.DataBind();
        }
    }

}